"use strict";

const Controller = require("egg").Controller;

class BrokerController extends Controller {
  // 获取订单管理列表
  async index() {
    const { ctx, app } = this;
    let { value = "", state = "" } = ctx.request.body;
    const data = await app.mysql.query(
      `select * from brokers where name like '%${value}%' and state like '%${state}%'`
    );
    ctx.body = {
      code: 200,
      data,
    };
  }

  // 订单管理删除
  async delete() {
    const { ctx, app } = this;
    const { id } = ctx.request.body;
    await app.mysql.delete("brokers", { id });
    ctx.body = {
      code: 200,
      mess: "删除成功",
    };
  }

}

module.exports = BrokerController;
